import 'package:flutter/material.dart';

class StepDemo extends StatefulWidget {
  @override
  _StepDemoState createState() => _StepDemoState();
}

class _StepDemoState extends State<StepDemo> {
  int _curentStep = 1;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Stepper(
      currentStep: _curentStep,
      onStepContinue: next,
      onStepCancel: cancel,
      steps: [
        Step(
          title: Text("标题"),
          subtitle: Text("我是子标题"),
          content: Text("我是内容"),
          isActive: _curentStep == 0,
        ),
        Step(
          title: Text("标题"),
          subtitle: Text("我是子标题"),
          content: Text("我是内容"),
          isActive: _curentStep == 1,
        ),
        Step(
          title: Text("标题"),
          subtitle: Text("我是子标题"),
          content: Text("我是内容"),
          isActive: _curentStep == 2,
        ),
      ],
    );
  }

  void next() {
    if (_curentStep >=2) {
      _curentStep = 0;
    }
    setState(() {
      _curentStep++;
    });
  }

  void cancel() {
    if(_curentStep>0){
      setState(() {
        _curentStep--;
      });
    }
  }
}
